package com.example.algorithm.aPrimarySort;

/**
 * @author: dangwen
 * @createDate: 2021/7/1
 */
public class BubbleSort {

    public static void sort(int[] arr){
        int temp;
        for (int i = 0; i < arr.length; i++) {
            for (int j = i; j < arr.length; j++) {
                if(arr[i] < arr[j]){
                    temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        int[] arr = {4,6,7,2,20,0,5,9};
        sort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
